import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:oli/pages/splash/logic.dart';

class SplashPage extends StatelessWidget {
  const SplashPage({super.key});
  @override
  Widget build(BuildContext context) {
    final logic = Get.find<InitLogic>();
    return Scaffold(
      backgroundColor: Colors.white,
      body: Center(
        child: Obx(() {
          if (logic.opacityAnimation.value == null) {
            return Container();
          }
          return FadeTransition(
            opacity: logic.opacityAnimation.value!,
            child: Obx(() {
              if (logic.scaleAnimation.value == null) {
                return Container();
              }
              return ScaleTransition(
                scale: logic.scaleAnimation.value!,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                      children: [
                        Obx(() {
                          if (logic.icon1SlideAnimation.value == null) {
                            return Container();
                          }
                          return SlideTransition(
                            position: logic.icon1SlideAnimation.value!,
                            child: Icon(
                              Icons.speed,
                              size: 80,
                              color: Colors.blue.withOpacity(0.7),
                            ),
                          );
                        }),
                        Obx(() {
                          if (logic.icon2SlideAnimation.value == null) {
                            return Container();
                          }
                          return SlideTransition(
                            position: logic.icon2SlideAnimation.value!,
                            child: Container(
                              decoration: BoxDecoration(
                                color: Colors.blue.withOpacity(0.1),
                                borderRadius: BorderRadius.circular(20),
                              ),
                              padding: const EdgeInsets.all(20),
                              child: Icon(
                                Icons.local_gas_station,
                                size: 120,
                                color: Colors.blue,
                              ),
                            ),
                          );
                        }),
                        Obx(() {
                          if (logic.icon3SlideAnimation.value == null) {
                            return Container();
                          }
                          return SlideTransition(
                            position: logic.icon3SlideAnimation.value!,
                            child: Icon(
                              Icons.calendar_today,
                              size: 80,
                              color: Colors.blue.withOpacity(0.7),
                            ),
                          );
                        }),
                      ],
                    ),
                    const SizedBox(height: 30),
                    Text(
                      '欢迎使用油耗计算工具',
                      style: TextStyle(
                        fontSize: 28,
                        fontWeight: FontWeight.bold,
                        color: Colors.blue,
                        fontFamily: 'Roboto',
                      ),
                    ),
                    const SizedBox(height: 10),
                    Text(
                      '精准记录，轻松掌握您的油耗情况',
                      style: TextStyle(
                        fontSize: 18,
                        color: Colors.grey[600],
                        fontFamily: 'Roboto',
                      ),
                    ),
                  ],
                ),
              );
            }),
          );
        }),
      ),
    );
  }
}
